package com.esteel.settlement.controller;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.esteel.settlement.entity.TbSettAccount;
import com.esteel.settlement.service.SettAccountService;
import com.esteel.settlement.service.SettPayService;
import com.esteel.settlement.vo.SettPayVo;

/**
 * 交易网 申请支付操作接口
 * @author zhangxiuzhi
 *
 */
@RestController()
public class PayController {

	private Logger logger =  LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private SettPayService settPayService;
	

	@Autowired
	private SettAccountService settAccountService;
	/**
	 * 支付发起接口
	 * @param model
	 * @param settPay
	 */
	@RequestMapping("/pay/pay")
	public String pay(Model model,SettPayVo settPay){
		logger.info("支付申请 付款方:{} 收款方:{} 金额:{} 手续费{}",settPay.getOutThirdCustId(),settPay.getInThirdCustId(),settPay.getTranAmount(),settPay.getHandFee() );
		Map<String, String> rsp = settPayService.pay(settPay);
		String result ="rspCode="+rsp.get("rspCode")+"&rspMsg="+rsp.get("rspMsg");
		logger.info(result);
		return result;
		
	}

//	/**
//	 * 客户取消付款
//	 * @param paySerialNo
//	 * @return
//	 */
//	@RequestMapping("/cancelPay")
//	public String cancelPay(String paySerialNo){
//		logger.info("取消付款 paySerialNo: {}",paySerialNo);
//		Map<String, String> rsp = settPayService.payCancel(paySerialNo);
//		String result ="rspCode="+rsp.get("rspCode")+"&rspMsg="+rsp.get("rspMsg");
//		logger.info(result);
//		return result;
//	}

}
